﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiAgency
    {
        public int AgencyId { get; private set; }
        public string AgencyName { get; private set; }
        public int AllianceId { get; private set; }
        public string AllianceName { get; private set; }
        public int OwnerAgencyId { get; private set; }
        public string OwnerAgencyName { get; private set; }
        public string OwnerName { get; private set; }
        public int OwnerPlayerId { get; private set; }

        public ApiAgency()
        {
        }

        public ApiAgency(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    switch (reader.Name)
                    {
                        case "a:agency_id": AgencyId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:agency_name": AgencyName = ApiXmlNode.GetValue(reader); break;
                        case "a:alliance_id": AllianceId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:alliance_name": AllianceName = ApiXmlNode.GetValue(reader); break;
                        case "a:owner_agency_id": OwnerAgencyId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                        case "a:owner_agency_name": OwnerAgencyName = ApiXmlNode.GetValue(reader); break;
                        case "a:owner_name": OwnerName = ApiXmlNode.GetValue(reader); break;
                        case "a:owner_player_id": OwnerPlayerId = int.Parse(ApiXmlNode.GetValue(reader)); break;
                    }
                }
            }
        }
    }
}
